// JavaScript source code
import { downLoad } from '@/api/download';

export function download(filePath, fileName) {
    downLoad({ fileName: filePath }).then(res => {
        var content = res;
        var blob = new Blob([content]);
        if ("download" in document.createElement("a")) {
            var elink = document.createElement("a");
            elink.download = fileName;
            elink.style.display = "none";
            elink.href = URL.createObjectURL(blob);
            document.body.appendChild(elink);
            elink.click();
            URL.revokeObjectURL(elink.href);
            document.body.removeChild(elink);
        }
        else {
            navigator.msSaveBlob(blob, fileName);
        }
    });
}
